/**
 * 
 */
package org.paybiz.core.payplatform.yeePay.constant;

import java.util.HashMap;
import java.util.Map;


/**
 * @author nassir wen
 * @data 2012-4-5 上午11:48:41
 * @version V2.5
 */
public final class RechargeCardConstant {

    private static Map<Integer, String> rechargeCardResultMap = new HashMap<Integer, String>();
    
    private static Map<Integer,String> rechargeCardCommitResultMap = new HashMap<Integer, String>();
    
    private static Map<Integer,Enum<RechargeCardType>> rechargeCardTypeEnumMap = new HashMap<Integer, Enum<RechargeCardType>>();
    
    static {
        if(rechargeCardCommitResultMap.isEmpty()) {
            for(RechargeCardCommitResult r: RechargeCardCommitResult.values()) {
                rechargeCardCommitResultMap.put(r.key, r.value);
            }
        }
        
        if(rechargeCardResultMap.isEmpty()) {
            for(RechargeCardResult r: RechargeCardResult.values()) {
                rechargeCardResultMap.put(r.key, r.value);
            }
        }
        
        if(rechargeCardTypeEnumMap.isEmpty()) {
            for(RechargeCardType t: RechargeCardType.values()) {
                rechargeCardTypeEnumMap.put(t.key, t);
            }
        }
        
    }
    /**
     * 充值卡类型
     */
    public static enum RechargeCardType {
        SZX(1001,"移动卡"),//神州行 
        UNICOM(1002,"联通卡"), 
        TELECOM(1003,"电信卡");
        //以下未开通
//        JUNNET(1004,"骏网一卡通"), 
//        SNDACARD(1005,"盛大卡"), 
//        ZHENGTU(1006,"征途卡"), 
//        QQCARD(1007,"Q币卡"), 
//        JIUYOU(1008,"久游卡"), 
//        YPCARD(1009,"易宝e卡通"), 
//        NETEASE(1010,"网易卡"), 
//        WANMEI(1011,"完美卡"), 
//        SOHU(1012,"搜狐卡"), 
//        ZONGYOU(1013,"纵游一卡通"), 
//        TIANXIA(1014,"天下一卡通"), 
//        TIANHONG(1015,"天宏一卡通");
        
        private final int key;
        private final String value;
        
        private RechargeCardType(int k, String v) {
            this.key = k;
            this.value = v;
        }
        
        public int key() {
            return this.key;
        }
        
        public String value() {
            return this.value;
        }
    }
    /**
     *  充值卡提交返回结果 
     */
    public static enum RechargeCardCommitResult {
        COMMIT_SUCCESS(1, "提交成功"),
        SIGN_FAIL_OR_OTHER_ERROR(-1,"签名较验失败或未知错误"),
        CARD_ALREADY_HANDLE(2,"卡密成功处理过或者提交卡号过于频繁"),
        EXCESSIVE_CARD_QUANTITY(5,"卡数量过多，目前最多支持10张卡"),
        ORDERID_DUPLICATE(11,"订单号重复"),
        PAY_AMOUNT_ERROR(66,"支付金额有误"),
        PAY_TYPE_NOT_OPEN(95,"支付方式未开通"),
        CARD_TYPE_NOT_OPEN(112,"业务状态不可用，未开通此类卡业务"),
        CARD_AMOUNT_ERROR(8001,"卡面额组填写错误"),
        CARD_PASSWD_OR_QUANTITY_ERROR(8002,"卡号密码为空或者数量不相等（使用组合支付时）");
        
        private final int key;

        private final String value;
        
        private RechargeCardCommitResult(int k, String v) {
            this.key = k;
            this.value = v;
        }
        
        public int key() {
            return this.key;
        }
        
        public String value() {
            return this.value;
        }
    }
    
    /**
     * 充值卡支付返回结果常量
     */
    public static enum RechargeCardResult{
        CARD_SUC_AND_ORDER_SUC(0,"销卡成功，订单成功"),
        CARD_SUC_AND_ORDER_FAIL(1,"销卡成功，订单失败"),
        ORDER_FAIL(2,"支付失败"), //非易宝状态
        CARD_INFO_ERROR(7,"卡号卡密或卡面额不符合规则"),
        CARD_COMMIT_FREQUENTLY(1002,"本张卡密您提交过于频繁，请您稍后再试"),
        CARD_TYPE_NOT_SUPPORT(1003, "不支持的卡类型（比如电信地方卡）"),
        PASSWD_ERROR_OR_CARD_INVALID(1004, "密码错误或充值卡无效"),
        CARD_INVALID(1006, "充值卡无效"),
        CARD_BALANCE_NOT_ENOUGH(1007, "卡内余额不足"),
        CARD_BALANCE_HAS_EXPIRED(1008, "余额卡过期（有效期1个月）"),
        CARD_PROCESSING(1010, "此卡正在处理中"),
        UNKNOW_ERROR(10000, "未知错误"),
        CARD_HAS_BEEN_USED(2005, "此卡已使用"),
        CARD_PASSWD_PROCESSING(2006, "卡密在系统处理中"),
        CARD_IS_COUNTERFEIT(2007, "该卡为假卡"),
        CARD_MAINTENANCE(2008, "该卡种正在维护"),
        ZHEJIANG_CARD_MAINTENANCE(2009, "浙江省移动维护"),
        JIANGSU_CARD_MAINTENANCE(2010, "江苏省移动维护"),
        FUJIAN_CARD_MAINTENANCE(2011, "福建省移动维护"),
        LIAONING_CARD_MAINTENANCE(2012, "辽宁省移动维护"),
        CARD_HAS_BEEN_LOCKED(2013, "该卡已被锁定"),
        SYSTEM_BUSY(2014, "系统繁忙，请稍后再试"),
        //下面为易宝e卡通返回的错误代码
        YEECARD_NOT_EXIST(3001, "易宝e卡不存在"),
        YEECARD_HAS_BEEN_USED(3002, "易宝e卡已使用过"),
        YEECARD_INVALID(3003, "易宝e卡已作废"),
        YEECARD_FREEZED(3004, "易宝e卡已冻结"),
        YEECARD_NOT_ACTIVATE(3005, "易宝e卡未激活"),
        YEECARD_PASSWD_ERROR(3006, "易宝e密码不正确"),
        YEECARD_PROCESSING(3007, "易宝e卡正在处理中"),
        YEECARD_SYSTEM_ERROR(3101, "易宝e系统错误"),
        YEECARD_HAS_EXPIRED(3102, "易宝e卡已过期");
        
        private final int key;
        private final String value;
        
        private RechargeCardResult(int k, String v) {
            this.key = k;
            this.value = v;
        }
        
        public int key() {
            return this.key;
        }
        
        public String value() {
            return this.value;
        }
    }
    
    public static String getRecargeCardCommitResultValue(int key) {
        return rechargeCardCommitResultMap.get(key);
    }
    
    public static String getRechargeCardResultValue(int key) {
       return rechargeCardResultMap.get(key);
    }
    
    public static Enum<RechargeCardType> getRechargeCardTypeEnum(int key) {
        return rechargeCardTypeEnumMap.get(key);
     }
}
